from django.shortcuts import render
from django.http import HttpResponse
from django.views import View
# Create your views here.
# def login(request):
#     return render(request,'login.html')
# def login(request):
#     return HttpResponse('没有收到了GET请求')
#函数视图
def login(request):
    if request.method=='POST':
        username=request.POST.get('username')
        password=request.POST.get('password')
        return HttpResponse(f"用户{username}的密码是{password}")
    elif request.method=='GET':
        return render(request,'login.html')
#类视图
class RegisterView(View):
    def get(self, request):
        return render(request, 'register.html')

    def post(self, request):
        username = request.POST.get('username')
        password = request.POST.get('password')
        password2 = request.POST.get('password2')
        # 业务逻辑判断
        return HttpResponse(f"用户{username}的密码是{password}")
